hsc

Macros

Okay, here are some examples of macro definitions:

Use as a shortcut

You can define a macro called MY_ADDRESS that only is a shortcut for your email-address like
<$MACRO MY_ADDRESS>hugo@some.where</$MACRO>
So every time, you insert the macro-tag
<MY_ADDRESS>
in your HSC-source, it will be replaced with the email address seen above in the HTML-file.

Create your own logical style

One of the most embarassing facts within HTML are physical/logical styles. Taking a look at the HTML 3.0 proposed things, you find loads of new styles: <AU> for authors, <SAMP> for sequences of litteral characters and so on... No one knows where this will end, and I'm just waiting for physical styles like <TIM_BERNERS_LEE_S_LOGICAL_STYLE_TO_RENDER_NAMES_OF_HIS_FRIENDS>.

Anyway, while other people think about which logical style should get his own tag and which not, you can define your own styles. For example, a logical style to render a filename could look like this:

<$MACRO FNM> <I> </$MACRO>
<$MACRO /FNM> </I> </$MACRO>
Your new style can be used like all other styles:
..open the file <FNM>hugo.txt</FNM> and..
In this case, filenames will be rendered italic. This seems much more reasonable to me then producing heaps of logical styles, but..

Note that you just created a container that requires an openig and closing tag.

Macros with custom attributes

Now the most subtile part starts: you can add attributes to macros. Attributes are compareable to function arguments in programming languages like Pascal, Oberon or E.

An attribute is defined with

name ":" type [ "=" default value ]
Legal attribute types are: So here's an example to understand that rather theoretical excess you just read and didn't understand at all:
<$MACRO BUTTON_NEXT NXTREF:uri>
<A HREF=<NXTREF>>
<IMG SRC="image/next.gif" ALT="Next">
</A>
</$MACRO>
This defines a macro that defines a button that references to the next page. As every page has its own next page, you can set one attribute for this macro: NXTREF, which is the URI that should be referenced as the "next" page.

So an example usage of this macro would be:

<BUTTON_NEXT NXTREF="sepp.html">
Note that the value of NXTREF is passed to the HREF attribute within the <A> tag when the macro is extracted.

If an attribute should get its value from an other attribute, the source attributes name needs to be enclosed in "<..>", like HREF=<NXTREF> (see above), which assigns the value of the macro attribute NXTREF to the tag attribute HREF.

Some Notes

Names for macros and attributes are case-insensitive.

Macro attributes can only be defined within opening macros. The coresponding closing macro automatically inherits all attributes of its opening macro. This seems more HTML-like to me.

This is not all that can be told about hsc's macros. Macros also support default values and several flags. Yeah, I really should improve the docs.. If you want to take a look at some quite complex macros, take a look at the file src_docs/inc/macro.hsc in this distribution.

MAIN PREV NEXT


Thomas Aglassinger ( agi@sbox.tu-graz.ac.at ), 09-Oct-1995, 10:59